package org.demo.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class Aop {

    // 匹配org.demo.config下cronjob方法
    @Pointcut("execution(* org.demo.config.*.cronjob(..))")
    public void pointcut() {
    }

    @Before("pointcut()")
    public void beforeAdvice(JoinPoint joinPoint) {
        System.out.println("切点before执行: " + joinPoint.getSignature().getName());
    }


    @After("pointcut()")
    public void afterAdvice(JoinPoint joinPoint) {
        System.out.println("切点after执行: " + joinPoint.getSignature().getName());
    }
}
